/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-01-12 09:35:49
 * @LastEditTime : 2023-05-05 15:12:46
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Modal\TwoModalList\ProjectCompanyMonthReport.jsx
 * @Description  :
 */
import dayjs from 'dayjs'
import { API_LIST } from '../../Api/Api'
import { TwoAddBtn, ThrDeleteBtn, OpenThrBtn } from '../options'
export const ProjectCompanyMonthReport = async ({ upDataEvent, data, Permission }) => {
    let dataList = {
        type: '公司月报列表',
        hideInSearch: true,
        pageSize: 10,
        params: { OrderField: 'yearMonth@desc' },
        classification: 'TableModal',
        get: API_LIST([data.uuid])['getProjectCompanyMonthReport'],
        additional: { key: 'organizationUuid', value: 'organizationUuid' },
        options: [
            Permission.findIndex(v => v.uuid === 'ae1980ed-9e0f-4922-967b-0ab62008ed0e') !== -1 && (
                <TwoAddBtn
                    upDataEvent={upDataEvent}
                    title="添加月报"
                    ThrKey="ThrModal"
                    value="ProjectCompanyMonthReport"
                    data={data}
                />
            ),
        ],
        columns: [
            {
                dataIndex: 'tableName',
                title: '月报名称',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'yearMonth',
                title: '月报月份',
                valueType: 'input',
                render: (_, { yearMonth }) => <div>{dayjs(yearMonth).format('YYYY-MM')}</div>,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                title: '创建时间',
                dataIndex: 'createTime',
                valueType: 'input',
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 500,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '0f1f68ff-de4d-403b-861d-e6e291d3a959') !== -1 && (
                            <OpenThrBtn
                                key="openThr"
                                upDataEvent={upDataEvent}
                                title="添加附件"
                                ThrKey="ThrModal"
                                value="ProjectCompanyMonthReportAttachment"
                                data={record}
                            />
                        ),
                        <OpenThrBtn
                            key="openThrList"
                            upDataEvent={upDataEvent}
                            title="附件详情"
                            ThrKey="ThrModal"
                            value="ProjectCompanyMonthReportAttachmentList"
                            data={{
                                ...record,
                                get: 'getProjectCompanyMonthReportAttachment',
                                del: 'delProjectCompanyMonthReportAttachment',
                            }}
                        />,
                        Permission.findIndex(v => v.uuid === 'de0277a1-0229-48d3-82e8-76d22656f391') !== -1 && (
                            <ThrDeleteBtn
                                key="delete"
                                record={record.uuid}
                                upDataEvent={upDataEvent}
                                data={{ key: 'delete', url: 'delProjectCompanyMonthReport', title: '删除附件' }}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return dataList
}
